package main

import (
	"fmt"
	"os"
)

// ioutil.ReadFile 读取整个文件
func main() {
	file, err := os.OpenFile("./xx.txt", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
	if err != nil {
		fmt.Println("open file failed, err:", err)
		return
	}
	defer file.Close()
	str := "hello world\n"
	file.Write([]byte(str))
	file.WriteString("深圳彭于晏")
}
